home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
c
/
dice-3.16.lha
/
doc
/
amiga.doc
< prev
next >
Wrap
Text File
|
1993-07-06
|
20KB
|
829 lines
AMIGA.DOC (c)Copyright 1990, Matthew Dillon, All Rights Reserved
TABLE OF CONTENTS
c.lib/amiga/alloca.a
c.lib/amiga/c.a
c.lib/amiga/chkabort
c.lib/amiga/_divs
c.lib/amiga/_divu
c.lib/amiga/exec_dcc
c.lib/amiga/_ExecSeg
c.lib/amiga/exit
c.lib/amiga/main
c.lib/amiga/onbreak
c.lib/amiga/_mods
c.lib/amiga/_modu
c.lib/amiga/_muls
c.lib/amiga/_mulu
c.lib/amiga/_SearchPath
c.lib/amiga/_SearchResident
c.lib/amiga/stack_abort
c.lib/amiga/wbmain
c.lib/amiga/x.a
c.lib/amiga/rega4
amiga/alloca amiga/alloca
NAME
alloca - allocate memory from the stack
SYNOPSIS
void *ptr = alloca(long bytes);
FUNCTION
alloca() comes from the UNIX world. It allocates memory off the
stack for use within a procedure. The allocated memory is
automatically freed when the subroutine returns.
DO NOT USE ALLOCA() IF YOU CAN HELP IT. alloca() is not easily
portable across machines.
NOTE
When a low stack condition arises, alloca() will abort by printing
an error message and calling abort(); alloca() does NOT currently
try to allocate dynamic memory when it runs out of stack.
Some implementations of alloca() use alloca(0) to free allocated
stack. This feature is NOT currently implemented in DICE's
alloca() call.
EXAMPLE
#include <alloca.h>
#include <stdio.h>
main(ac, av)
char *av[];
{
char *ptr;
if (ac == 1) {
puts("test string");
exit(1);
}
ptr = alloca(strlen(av[1]) + 8);
sprintf(ptr, "FOO.%s", av[1]);
puts(ptr);
return(0);
}
SEE ALSO
setjmp(), longjmp()
amiga/c.a amiga/c.a
NAME
c.a - DICE startup module for all C programs
SYNOPSIS
c.a is entered when the program segment is run
FUNCTION
DCC specifies DLIB:C.O first when linking objects into an
executable. C.O also exists in C.LIB but is not normally pulled
since it is already included in the link line.
C.O does the following:
(1) save non-scratch registers
(2) If Resident:
Allocate space for both data & bss and copy the
initialized data into the allocated space. Clear
the BSS portion of the data space
Else
The BSS has already been allocated by the load module
but not cleared, Clear the BSS portion of the data space
(3) Clear the ^C signal
(4) Setup _SysBase
(5) Call all AUTOINIT subroutines (this usually results in at
least the dos.library being openned).
(6) call _main() (usually in c.lib as well)
(7) fall through to _exit(0)
Note that while c.a falls through to _exit(0) after calling _main(),
_main itself calls main() with: exit(main(args...)); Thus, main()
is always expected to return a valid value (i.e. not void).
C.O also handles the low level exit _exit() (__exit:) in the
following sequence:
(1) Call autoinit exit subroutines (this normally closes the
DOS library and other automatically openned libraries such
as floating point libraries).
(2) Free all memory allocated by the task, including the small
data segment & BSS space. Note that all variables that we
use after this have already been placed in registers since
the dataspace is no longer valid.
(3) If the _WBMsg is not NULL then:
(a) Forbid()
(b) ReplyMsg(_WBMsg)
(4) restore original registers and rts (exit out of the process)
NOTE
Normally the programmer does not overide the startup object file
(c.o) since this is the entry point into the program. However, in
many cases a programmer will want to overide _main(). I.E.:
_main(len, arg)
int len;
char *arg;
{
...
}
In which case he is given the length and arg pointer passed to the
program on startup. When you overide _main() you cannot call any
stdio (fopen, fclose, puts, etc...), low level IO (open, close,
read, write, etc...), or memory allocation routines.
Normally _main will be overriden if the program makes only system
calls (such as Open, Close, Read, Write, FindTask, etc...).
Overriding the c.lib generally makes executables much smaller as no
extranious stdio/low level IO routines are brought in from c.lib .
Normally you exit out of _main by calling _exit(code) (note the
underscore).
SEE ALSO
amiga/chkabort amiga/chkabort
NAME
chkabort - check for ^C and take the appropriate action
SYNOPSIS
(void) chkabort(void);
FUNCTION
Checks for a ^C and takes the appropriate action. If the appropriate
action is to exit than this routine does not return. stdio and other
routines will call chkabort() at various points.
The action taken by ^C may be set by the signal() or onbreak() calls.
EXAMPLE
/*
* wait for somebody to hit ^C (note that this is very wasteful of
* CPU and thus isn't a real good example).
*/
main()
{
int i;
for (i = 0; i < 10000000; ++i)
chkabort();
return(0);
}
SEE ALSO
onbreak, atexit, signal
amiga/_divs amiga/_divs
NAME
_divs - signed long divide 32/32->32 assembly tag
not callable from C
ENTRY
D0 = 32 bit signed integer
D1 = 32 bit signed integer
RETURN
D0 = D0 / D1
FUNCTION
This is an assembly function that DICE uses whenever it needs to
do a long division. This function is not callable from C.
SEE ALSO
_divu, _mods, _modu, _muls, _mulu
amiga/_divu amiga/_divu
NAME
_divu - unsigned long divide 32/32->32 assembly tag
not callable from C
ENTRY
D0 = 32 bit unsigned integer
D1 = 32 bit unsigned integer
RETURN
D0 = D0 / D1
FUNCTION
This is an assembly function that DICE uses whenever it needs to do
an unsigned long division. This function is not callable from C.
SEE ALSO
_divs, _mods, _modu, _muls, _mulu
amiga/exec_dcc amiga/exec_dcc
NAME
exec_dcc - call DICE executable
FUNCTION
DO NOT EVER USE THIS FUNCTION. This is an internal DICE function
used by DCC and is subject to change without notice. This function
can easily break under new versions of the OS and special care is
taken by DCC when using it.
The 2.0 version of the Amiga operating system has calls that will
properly accomplish this operation.
SEE ALSO
_ExecSeg
amiga/_ExecSeg amiga/_ExecSeg
NAME
_ExecSeg - call a segment
FUNCTION
DO NOT EVER USE THIS FUNCTION. This is an internal DICE function
used by DCC and is subject to change without notice. This function
can easily break under new versions of the OS and special care is
taken by DCC when using it.
The 2.0 version of the Amiga operating system has calls that will
properly accomplish this operation.
SEE ALSO
exec_dcc
amiga/exit amiga/exit
NAME
exit - exit from a program 'nicely'
SYNOPSIS
(void) exit(code)
FUNCTION
exits the program and returns the specified exit code. Normally you
pass 0 to indicate no errors, a positive number to indicate a program
error to the parent.
exit() closes all stdio file pointers, low level file descriptors,
perhaps other things, then finally calls _exit with the code.
If you use main() you should call exit() to exit the program or
return an error code from main. If you use the _main() entry
point (only for programmers dead set on optimizing executable
size and using only system library calls) you should use the _exit()
exit point.
EXAMPLE
main(ac, av)
char *av[];
{
if (ac <= 1) {
puts("I expected an argument you idiot!");
exit(1);
}
puts("thanks for the argument!");
exit(0);
}
SEE ALSO
main, _main, _exit
amiga/_exit amiga/_exit
NAME
_exit - exit from a program without bother to release resources
SYNOPSIS
(void) _exit(code)
int code;
FUNCTION
exits the program and returns the specified exit code. Normally you
pass 0 to indicate no errors, a positive number to indicate a program
error to the parent. Note that since auto-init openned libraries
are closed in the startup module (c.o), automatically openned
libraries WILL be automatically closed for you. However, any
libraries you manually declare the library base variable for and
manually open must be closed by you.
You should only call _exit() if you used the _main() entry point
(instead of the usual main()), and then only